package com.lcache.core.service.impl;

import com.lcache.common.redis.RedisService;
import com.lcache.core.service.Level2Cache;

/**
 * @program: lcache
 * @description: redis缓存
 * @author: Alex Wu
 * @createDate: 2025-04-17 17:35
 **/
public class RedissonCache implements Level2Cache {

    private RedisService  redisService;


    public RedissonCache(){
        redisService = new RedisService();
    }
    /**
     * 获取缓存
     *
     * @param key 缓存key
     * @return 缓存值
     */
    @Override
    public Object get(String key) {
        if(key == null){
            return null;
        }
        return redisService.get(key);
    }

    /**
     * 设置缓存
     *
     * @param key   缓存key
     * @param value 缓存值
     */
    @Override
    public void set(String key, Object value) {
        redisService.set(key, value.toString(), 10);
    }

    /**
     * 删除缓存
     *
     * @param key 缓存key
     */
    @Override
    public void delete(String key) {
        redisService.delete(key);
    }
}
